package com.components.project

import android.widget.LinearLayout
import com.components.project.ui.base.ProjectBaseActivity

/**
 * @Author LuoKun
 * @Des
 */
class X5Activity : ProjectBaseActivity() {

    private val llContainer: LinearLayout by lazy {
        findViewById(R.id.llContainer)
    }

    private var x5Fragment: X5Fragment? = null

    override fun layoutId(): Int {
        return R.layout.activity_x5
    }

    override fun initView() {
        initFragment()
    }

    override fun initData() {

    }

    private fun initFragment() {
        val supportFragmentManager = supportFragmentManager
        val beginTransaction = supportFragmentManager.beginTransaction()
        if (x5Fragment == null) {
            x5Fragment = X5Fragment()
            val bundle = intent.extras
            x5Fragment?.let {
                it.arguments = bundle
                beginTransaction.add(R.id.llContainer, it)
            }
        } else {
            beginTransaction.show(x5Fragment!!)
        }
        beginTransaction.commit()
    }

//    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
//        return if (keyCode == KeyEvent.KEYCODE_BACK) {
//            if (x5Fragment?.x5WebView != null && x5Fragment?.x5WebView?.canGoBack() == true) {
//                x5Fragment?.x5WebView?.goBack()
//                true
//            } else super.onKeyDown(keyCode, event)
//        } else super.onKeyDown(keyCode, event)
//    }

}